 <include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('company/stationIndex')}">岗位信息</a></li>
		<li><a href="{:url('company/stationAdd')}">添加岗位信息</a></li></li>
        <li class="active"><a>编辑岗位信息</a></li>
    </ul>
    <!--js-ajax-form-->
    <form class="form-horizontal  margin-top-20"
     action="{:url('company/stationEditPost')}" method="post">
        <div class="form-group">
            <label for="input-departID" class="col-sm-2 control-label">部门名称</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" onchange="searchStation()" name="departID" id="input-depart_id">
                    <option value="0">作为一级菜单</option>{$select_category}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-stationID" class="col-sm-2 control-label"><span class="form-required">*</span>岗位名称</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="stationID" id="select_station"
                           >
                    <foreach name="result_st" item="vo">
                        <option {$vo.select} value="{$vo.stationID}">{$vo.stationName}</option>{$vo.stationName}
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-stationCode" class="col-sm-2 control-label">岗位编码</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-stationCode" name="stationCode" value="{$stdata.stationCode}">
            </div>
        </div>
       
       
		<div class="form-group">
            <label for="input-workArea" class="col-sm-2 control-label">管控区域</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-workArea" name="workArea" value="{$stdata.workArea}">
            </div>
        </div>
		 <div class="form-group">
				<label for="input-stDangerLevelID" class="col-sm-2 control-label"><span class="form-required"></span>风险等级</label>
				<div class="col-md-6 col-sm-10">
					<select class="form-control" name="stDangerLevelID" id="input-stDangerLevelID">
						<foreach name="levelData" item="vo">
							<option {$vo.selected} id = '{$vo.dangerLevelID}' value='{$vo.dangerLevelID}'>{$vo.dangerLevelName}</option>
						</foreach>
					</select>
				</div>
			</div>

        <div class="form-group">
         	<div class="col-sm-offset-2 col-sm-10">
                <input type="hidden" name="stationID" value="{$stdata.stationID}"/>
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
                <a class="btn btn-default" 
                href="{:url('admin/company/stationIndex')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
        /*组织机构下拉框选择事件*/
        function searchStation() {
          //获取组织机构select 对象
           var selectDepartment = document.getElementById('input-depart_id');  
           //拿到选中项的索引：
           var index=selectDepartment.selectedIndex;
           //拿到选中项options的value：
           var departmentValue = selectDepartment.options[index].value;
           
           //拿到选中项options的text：
           //var departmentStr = (selectDepartment.options[index].text);
           var departmentText = selectDepartment.options[index].text;
           console.log(departmentValue);
           $.ajax({
               // url:"/index.php/admin/company/ajaxStation",
                url:"/admin/company/ajaxStation",
                data:{stationStr:departmentValue},
                type:"get",
                dataType:"json",
                success: function(data){
                    console.log(data);
                    $("#select_station").find("option").remove();
                     // $("#select_station").append("<option value=''>请选择</option>");
                    //动态给select 赋值
                    for(var i=0;i<data.length;i++){
                       $("#select_station").append("<option id = '"+ data[i]["stationID"]+"' value='"+ data[i]["stationID"] +"'>"+ data[i]["stationName"]+"</option>");
                    } 
                }
            });
        }
    </script>
</body>
</html>